<?php
    //debug($json_data);
?>

<table class="tablep ">
    <!--<tr>
        <td class="no-border" style="text-align: center"><?php /*echo $print_title;*/?></td>
    </tr>-->
    <tr>
        <th class="no-border" style="text-align: center"><?php echo $print_title;?></th>
    </tr>
</table>

<div style="display: block; clear:both;">&nbsp;</div>

<div style="float:left;">
    <table class="tablep">
        <tr>
            <th class="no-border no-background">To: </th><td class="no-border"><?php echo $json_data['Customer']['name'];?></td>
        </tr>
        <tr>
            <th class="no-border no-background">Address: </th><td class="no-border"><?php echo $json_data['Customer']['address'];?></td>
        </tr>
        <tr>
            <th class="no-border no-background">Tel: </th><td class="no-border"><?php echo $json_data['Customer']['phone_number'];?></td>
        </tr>
        <tr>
            <th class="no-border no-background">Date: </th><td class="no-border"><?php echo $json_data['Proforma']['created'];?></td>
        </tr>
        <tr>
            <th class="no-border no-background">Invoice No.: </th><td class="no-border"><?php echo $json_data['Proforma']['invoice_number'];?></td>
        </tr>

    </table>
</div>

<div style="display: block; clear:both;">&nbsp;</div>

<div>
    <table class="tablep table-bordered">
        <thead>
            <tr>
                <th>Quantity</th>
                <th>Description</th>
                <th>Unit Price</th>
                <th>Discount %</th>
                <th>Line Total</th>
            </tr>
        </thead>
        <tbody>
        <?php
        $grand = 0.00;
        foreach($json_data['ProformaItem'] as $item){
            $currency = $item['Item']['currency'];
            $total = $item['quantity'] * $item['Item']['amount'];
            $discount = $item['discount'];
            $dis_amt = ($discount/100) * $total;
            $bal = $total - $dis_amt;
            $grand = $grand + $bal;

        ?>
            <tr>
                <td><?php echo $item['quantity'];?></td>
                <td><?php echo $item['Item']['name'].' <br />'.$item['Item']['specs'];?></td>
                <td><?php echo $currency.' '.$controller->formatNumber($item['Item']['amount'],'money');?></td>
                <td><?php echo $item['discount'];?></td>
                <td><?php echo $currency.' '.$controller->formatNumber($bal,'money');?></td>
            </tr>
        <?php
            }
        ?>

        <tr>
            <td colspan="3">&nbsp;</td>
            <td><strong>Grand Total</strong></td>
            <td><strong><?php echo $currency.' '.$controller->formatNumber($grand,'money'); ?></strong></td>
        </tr>
        </tbody>
    </table>

    <div style="display: block; clear:both;">&nbsp;</div>
    <div style="display: block; clear:both;">&nbsp;</div>

    <table class="tablep ">
        <tr>
            <td class="no-border">OFFICER IN CHARGE &nbsp;</td><td class="no-border">CUSTOMER SIGN &nbsp;</td>
        </tr>
    </table>

    <div style="display: block; clear:both;">&nbsp;</div>

    <table class="tablep ">
        <tr>
            <th class="no-border  no-background"><?php echo strtoupper($json_data['Proforma']['officer_incharge']) ;?> <br /> <?php echo $json_data['Proforma']['fon_number'] ;?>  &nbsp;</th>
        </tr>
    </table>

    <table class="tablep ">
        <tr>
            <td class="no-border"><strong>BANK DETAILS:</strong> &nbsp; <?php echo $comp_acct_no; ?></td>
        </tr>
    </table>

    <div>
        <?php
        echo strtoupper($print_statement);
        ?>
    </div>

</div>